package safrain.nodelet.event;

import java.lang.reflect.Field;

import safrain.nodelet.pool.reseter.IReseter;
import safrain.nodelet.structure.FieldInfo;

/**
 * 重置事件原和监听器的Reseter
 * 
 * @author safrain
 */
public class EventObjectReseter implements IReseter {
	private Field field;

	@Override
	public void init(FieldInfo fieldInfo) {
		field = fieldInfo.field;
	}

	@Override
	public void reset(Object object) {
		try {
			IEventObject eventObject;
			eventObject = (IEventObject) field.get(object);
			if (eventObject == null)
				return;
			eventObject.destroy();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

}
